@import '../../assets/less/inc/variables';

.dashboard-wrapper {
  flex-grow: 1;
  margin-bottom: 70px;

  .layout {
    margin: -15px -15px 0;
  }

  .tile {
    display: flex;
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  .pivot-table-visualization-container > table,
  .visualization-renderer > .visualization-renderer-wrapper {
    overflow: visible;
  }

  &.preview-mode {
    .widget-menu-regular {
      display: block;
    }
    .widget-menu-remove {
      display: none;
    }
  }

  &.editing-mode {
    /* Y axis lines */
    background: linear-gradient(to right, transparent, transparent 1px, #F6F8F9 1px, #F6F8F9), linear-gradient(to bottom, #B3BABF, #B3BABF 1px, transparent 1px, transparent);
    background-size: 5px 50px;
    background-position-y: -8px;

    /* X axis lines */
    &::before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      bottom: 85px;
      right: 15px;
      background: linear-gradient(to bottom, transparent, transparent 2px, #F6F8F9 2px, #F6F8F9 5px), linear-gradient(to left, #B3BABF, #B3BABF 1px, transparent 1px, transparent);
      background-size: calc((100vw - 15px) / 6) 5px;
      background-position: -7px 1px;
    }
  }

  .dashboard-widget-wrapper:not(.widget-auto-height-enabled) {
    .visualization-renderer {
      display: flex;
      flex-direction: column;
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;

      > .visualization-renderer-wrapper {
        flex-grow: 1;
        position: relative;
      }

      > .filters-wrapper {
        flex-grow: 0;
      }
    }

    .sunburst-visualization-container,
    .sankey-visualization-container,
    .map-visualization-container,
    .word-cloud-visualization-container,
    .box-plot-deprecated-visualization-container,
    .chart-visualization-container {
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      width: auto;
      height: auto;
      overflow: hidden;
    }

    .counter-visualization-content {
      position: absolute;
      left: 10px;
      top: 15px;
      right: 10px;
      bottom: 15px;
      height: auto;
      overflow: hidden;
      padding: 0;
    }
  }

  .widget-auto-height-enabled {
    .spinner {
      position: static;
    }

    .scrollbox {
      overflow-y: hidden;
    }
  }
}

.profile__image_thumb--dashboard {
  width: 16px;
  height: 16px;
  border-radius: 100%;
  margin: 3px 5px 0 0;
}

.dashboard-header {
  position: -webkit-sticky;  // required for Safari
  position: sticky;
  background: #f6f7f9;
  z-index: 99;
  width: 100%;
  top: 0;
}

.dashboard-header, .page-header--query {
  .tags-control a {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
  }

  &:hover {
    .tags-control a {
      opacity: 1;
    }
  }
}

.dashboard__control {
  margin: 8px 0;

  .save-status {
    vertical-align: middle;
    margin-right: 7px;
    font-size: 12px;
    text-align: left;
    display: inline-block;

    &[data-saving] {
      opacity: 0.6;
      width: 45px;

      &:after {
        content: '';
        animation: saving 2s linear infinite;
      }
    }

    &[data-error] {
      color: #F44336;
    }
  }
}

@keyframes saving {
  0%, 100% {
    content: '.';
  }
  33% {
    content: '..';
  }
  66% {
    content: '...';
  }
}


// Mobile fixes
@media (max-width: 767px) {
  dashboard-page {
    .dashboard-header {
      padding: 0 !important;

      .page-title h3 {
        margin-bottom: 0 !important;
        font-size: 18px;
        line-height: 2;
      }

      .dashboard__control {
        margin: 5px 0;
      }
    }

    favorites-control {
      margin-top: 4px;
    }
  }
}

public-dashboard-page {
  > .container {
    min-height: calc(100vh - 95px);
  }

  #footer {
    height: 95px;
    text-align: center;
  }
}

/****
  grid bg - based on 6 cols, 35px rows and 15px spacing
****/

// let the bg go all the way to the bottom
dashboard-page, dashboard-page .container {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  width: 100%;
}

#dashboard-container {
  position: relative;
  flex-grow: 1;
  display: flex;
}

// soon deprecated
dashboard-grid {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.add-widget-container {
  background: #fff;
  border-radius: @redash-radius;
  padding: 15px;
  position: fixed;
  left: 15px;
  bottom: 20px;
  width: calc(~'100% - 30px');
  z-index: 99;
  box-shadow: fade(@redash-gray, 50%) 0px 7px 29px -3px;
  display: flex;
  justify-content: space-between;

  h2 {
    margin: 0;
    font-size: 14px;
    line-height: 2.1;
    font-weight: 400;

    .zmdi {
      margin: 0;
      margin-right: 5px;
      font-size: 24px;
      position: absolute;
      bottom: 18px;
    }

    span {
      padding-left: 30px;
    }
  }

  .btn {
    align-self: center;
  }
}
